package com.srd.phone.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shengrongdai.srd.R;
import com.srd.phone.bean.RefundDetail;
import com.srd.phone.utils.views.ViewHolder;

import java.util.ArrayList;
import java.util.List;

public class RefundDetailAdapter extends BaseAdapter {

    private Context context;
    private List<RefundDetail> list = new ArrayList<RefundDetail>(10);

    public RefundDetailAdapter(Context context, List<RefundDetail> list0) {
        this.context = context;
        list = list0;
    }

    public void setData(List<RefundDetail> list0) {
        list = list0;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public RefundDetail getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder viewHolder =  ViewHolder.get(context, view, parent, R.layout.item_refund_detail, position);

        RefundDetail item = getItem(position);
        TextView tv_title = viewHolder.getView(R.id.tv_title);
        tv_title.setText(item.nm);

        TextView tv_mode = viewHolder.getView(R.id.tv_mode);
        tv_mode.setText(item.numbersm);

        TextView tv_periods = viewHolder.getView(R.id.tv_periods);
        tv_periods.setText(item.num + "");

        TextView tv_date = viewHolder.getView(R.id.tv_date);
        tv_date.setText(item.rtime);

        TextView tv_state = viewHolder.getView(R.id.tv_state);
        tv_state.setText(item.rstatem + "");

        return viewHolder.getConvertView();
    }
}
